// pages/refund/refund.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // 隐藏货品图标
    hidd:true,
    hiddof:true,
    hiddeof:true,
    hidde: true,
    appear: true,
    appea:true,
    aniam:"",
    ani:"",
    chose:"请选择",
    content:"请选择",
    tempFilePaths:[]
  },
  // 货物状态弹窗与底部动画
  refund(){
    this.setData({
      appear: this.data.appear=false
    })
    this.PopUp();
  },
  // 未收到货
  not(){
    this.setData({
      hidd: !this.data.hidd,
    });
    if(this.data.hidd==false){
      this.setData({
        appear: !this.data.appear,
        chose:"未收到货",
        hidde: this.data.hidde=true
      })
      this.lnitialize();
    }else{
      this.setData({
        chose: "请选择"
      })
    }

  },
  // 已收到货
  next(){
    this.setData({
      hidde: !this.data.hidde,
    });
    if (this.data.hidde==false){
      this.setData({
        appear: !this.data.appear,
        chose: "已收到货",
        hidd: this.data.hidd=true
      })
      this.lnitialize();
    }else{
      this.setData({
        chose: "请选择"
      })
    }
    
  },
  // 关闭货物状态
  but(){
    this.lnitialize();
    this.setData({
      appear: this.data.appear = true
    });
  },
  // 退款原因
  why(){
    this.setData({
      appea:this.data.appea=false
    });
    this.PopUp();
  },
  // 调出动画
  PopUp(){
    this.aniama = wx.createAnimation({
      duration: 200,
      timingFunction: "linear"
    });
    this.aniama.bottom(0).step();
    this.setData({
      ani: this.aniama.export(),
    });

  },
  // 退出动画
  lnitialize(){
    this.aniama.bottom("-100%").step({
      duration: 200,
    });
    this.setData({
      ani:this.aniama.export(),
    });
   
  },
  notof(){
    this.setData({
      hiddof: !this.data.hiddof
    });
    if (this.data.hiddof == false) {
      this.setData({
        appea: !this.data.appea,
        content: "七天无理由退货",
        hiddeof: this.data.hiddeof = true
      })
      this.lnitialize();
    } else {
      this.setData({
        content: "请选择"
      })
    }
   
  },
  nextof(){
    this.setData({
      hiddeof: !this.data.hiddeof,
    });
    if (this.data.hiddeof == false) {
      this.setData({
        appea:!this.data.appea,
        content: "商品与不符合心意",
        hiddof: this.data.hiddof= true
      })
      this.lnitialize();
    } else {
      this.setData({
        content: "请选择"
      })
    }
   
  },
  // 关闭
  butof(){
    this.setData({
      appea: this.data.appea= true
    });
    this.lnitialize();
  },
  // 上传凭证
  evidence(){
    var that=this;
    wx.showActionSheet({
      itemList: ["相册","拍照"],
      success(res){
        console.log(res);
        if(res.tapIndex ==0){
          that.choose("album")
        }else{
          that.choose("camera")
        }
      }
    })
    
  },
  // 调用摄像头或者相册
  choose(type){
    var tha =this;
    wx.chooseImage({
      count: "3",
      sizeType: ['original', 'compressed'],
      sourceType:[type],
      success: function (res) {
        // console.log(res.tempFilePaths)
        wx.setStorage({
          key: 'setImg',
          data: res.tempFilePaths,
        });
        tha.getTem();
      },
    });
   
  },
  getTem(){
    var tha=this;
    wx.getStorage({
      key: 'setImg',
      success: function (res) {
        // console.log(res.data)
        tha.setData({
          tempFilePaths: res.data
        })
      },
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getTem();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})